<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .progress {
        border: solid;
      }
      .progress > div {
        height: 20px;
        /* margin: 5px; */
        width: 0%;
        background-color: blue;
        color: white;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <video width="300" id="video" controls></video>

    <script>
      const xhr = new XMLHttpRequest();
      const progressBar = document.getElementById("progressBar");
      xhr.open("GET", "http://127.0.0.1:8081/video ");
      // 将二进制封装成对象
      xhr.responseType = "blob";
      // URL.createObjectURL 将二进制对象内容转换为一个临时地址
      xhr.onload = function () {
        video.src = URL.createObjectURL(xhr.response);
      };
      xhr.send();
    </script>
  </body>
</html>
